﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Demo : MonoBehaviour {

	void Start () {
		TJSDK.Instance.Setup ();
	}

	void OnGUI(){
		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("展示开屏",GUILayout.Width(Screen.width),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("展示开屏");
			TJSDK.Instance.ShowSplash (SplashCallBack);
		}
		GUILayout.EndHorizontal ();

		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("展示Banner",GUILayout.Width(Screen.width/2),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("展示Banner");
			TJSDK.Instance.ShowBanner (BannerCallBack);
		}
		if(GUILayout.Button("关闭Banner",GUILayout.Width(Screen.width/2),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("关闭Banner");
			TJSDK.Instance.CloseBanner ();
		}
		GUILayout.EndHorizontal ();


		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("展示插屏",GUILayout.Width(Screen.width/2),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("展示插屏");
			TJSDK.Instance.ShowInsert (InsertCallBack);
		}
		if(GUILayout.Button("检测插屏状态",GUILayout.Width(Screen.width/2),GUILayout.Height(Screen.height/10f))){
			bool state = TJSDK.Instance.IsInsertReady ();
			Debug.Log ("插屏状态:" + state);
		}
		GUILayout.EndHorizontal ();

		#if lenovo
		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("展示激励视频",GUILayout.Width(Screen.width),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("展示激励视频");
			TJSDK.Instance.ShowIncentVideo (IncentCallBack);
		}
		GUILayout.EndHorizontal ();
		#endif

		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("分享",GUILayout.Width(Screen.width/2),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("分享");
			TJSDK.Instance.Share ("标题", "这里是内容", null, SDKData.SharePath,ShareCallBack);
		}
		if(GUILayout.Button("分享(微信)",GUILayout.Width(Screen.width/2),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("分享(微信)");
			TJSDK.Instance.Share (Platform.WEIXIN, "标题", "这里是内容", null, SDKData.SharePath,ShareCallBack);
		}
		GUILayout.EndHorizontal ();

		#if m4399 || oppo || vivo || iappay
		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("支付",GUILayout.Width(Screen.width),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("支付");
			TJSDK.Instance.PayAndroid ("1", "20钻石","获得20钻石",PayCallBack);
		}
		GUILayout.EndHorizontal ();
		#endif

		GUILayout.BeginHorizontal ();
		if(GUILayout.Button("退出游戏",GUILayout.Width(Screen.width),GUILayout.Height(Screen.height/10f))){
			Debug.Log ("退出游戏");
			TJSDK.Instance.QuitGame();
		}
		GUILayout.EndHorizontal ();
	}

	void SplashCallBack(bool success){
		if (success) {
			Debug.Log ("开屏已展示");
		} else {
			Debug.Log ("开屏展示失败");
		}
	}

	void BannerCallBack(bool success){
		if (success) {
			Debug.Log ("横幅已展示");
		} else {
			Debug.Log ("横幅展示失败");
		}
	}

	void InsertCallBack(bool success){
		if (success) {
			Debug.Log ("插屏已展示");
		} else {
			Debug.Log ("插屏展示失败");
		}
	}

	void IncentCallBack(bool success){
		if (success) {
			Debug.Log ("激励视频已展示");
		} else {
			Debug.Log ("激励视频展示失败");
		}
	}

	void ShareCallBack(bool success){
		if (success) {
			Debug.Log ("分享成功");
		} else {
			Debug.Log ("分享失败");
		}
	}

	void PayCallBack(bool success){
		if (success) {
			Debug.Log ("支付成功");
		} else {
			Debug.Log ("支付失败");
		}
	}
}
